In object-oriented programming, an "object" is a software package that contains a collection of related procedures (or "methods") and data (or "variables"). A "class" is a template that defines the methods and variables to be included in a particular object.
Once a base class is defined, any number of unique "instances" of the class may be created. The class defines the characteristics shared by all the instances, while the instance itself contains the information that makes the instance unique.
Inheritance is a mechanism whereby a new class of objects can be defined as a special case of a more general class. The new class automatically includes (or "inherits") the method and variable definitions of the general class. Special cases of a class are known as "subclasses" of that class. In addition to the methods and variables they inherit, subclasses may define their own methods and variables and may override any of the inherited characteristics. Inheritance is thus essentially a mechanism for extending an application's functionality by reusing the functionality in the parent classes.
Interfaces are fundamental in object-oriented systems. Objects are known only through their interfaces. An object's interface characterizes the complete set of requests that can be sent to the object, or methods recognized and implemented by the object. An object's interface says nothing about its implementation, i.e. different objects are free to implement different requests differently.
"Implementation inheritance" defines an object's implementation in terms of another object's implementation, i.e. implementation inheritance defines a new implementation in terms of one or more existing implementations. Implementation inheritance is thus essentially a mechanism for code and representation sharing. In contrast, "interface inheritance" (or subtyping) describes when an object can be used in place of another, i.e. interface inheritance defines a new interface in terms of one or more existing interfaces.
FIG. 1A illustrates an overview of object oriented programming concepts. Specifically, FIG. 1A illustrates two classes, Class A and Class B, each comprising multiple objects. Objects A.sub.1 and A.sub.2 are each instances of Class A and inherit all characteristics of Class A. Each object may also override any or all of the inherited characteristics. Similarly, Objects B.sub.1, B.sub.2 and B.sub.3 are instances of Class B and inherit all characteristics of Class B and may override any or all of the inherited characteristics. Class A also inherits from Interface X, where Interface X implements multiple methods. Class B inherits from both Interface X and Interface Y, where each interface implements multiple methods. Objects in Class A therefore recognize Methods X.sub.1, X.sub.2 and X.sub.3, while objects in Class B recognize Methods X.sub.1, X.sub.2, X.sub.3, Y.sub.1, Y.sub.2 and Y.sub.3.
In languages like C++, inheritance means both interface and implementation inheritance. The standard way to inherit an interface in C++ is to inherit publicly from a class that has (pure) virtual member functions. Pure interface inheritance can be approximated in C++ by inheriting publicly from pure abstract classes. Pure implementation or class inheritance can be approximated with private inheritance. In languages like Smalltalk, on the other hand, inheritance means implementation inheritance only. Instances of any class may be assigned to a variable as long as those instances support the operations performed on the value of the variable.
In contrast with C++ and Smailtalk, in a programming environment such as Java.TM., interface inheritance and implementation inheritance are treated distinctly differently. The issues facing a programmer in any of these object oriented programming environments, however, remain similar. The present specification assumes an interface inheritance mechanism implemented in Java. The description is, however, also applicable to a C++ or Smalltalk programming environment, with minor modifications.
Interface inheritance generally requires a mechanism to locate appropriate information about an interface with respect to the object being dealt with. For example, a mechanism is required to determine whether an object implements a specific method. FIG. 1B illustrates this problem conceptually. If "Method X.sub.3 " is called in Object A.sub.1, then a method table, method table 100, is accessed to determine whether Object A.sub.1 may implement Method X.sub.3. In order to find Method X.sub.3, method table 100 is searched in a linear, sequential manner.
Thus, as illustrated in this example, the search goes through each method in method table 100 and locates Method X.sub.3. Then, based on the address for Method X.sub.3, the method can be invoked. Note that Object A.sub.1 does not inherit from Interface Y, and thus half the methods in the method table are not applicable to Object A.sub.1. Given that a class can implement as many interfaces as a programmer chooses, searching for a specific method potentially involves checking all methods for each interface the object class implements for a match. This may result in a time-consuming loop to search for the item required.